define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'usermanage/userinfo/index',
                    add_url: 'usermanage/userinfo/add',
                    edit_url: 'usermanage/userinfo/edit',
                    del_url: 'usermanage/userinfo/del',
                    multi_url: 'usermanage/userinfo/multi',
                    table: 'user',
                }
            });

            var table = $("#table");

            // 初始化表格
             table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'uid',
                sortName: 'uid',
                search: false, //默认主键id搜索框
                showColumns:true,//选择要显示的列
                showToggle:true,//表格的显示样式
                searchFormVisible:false,//搜索框是否在顶部默认显示
                shwoExport:true,//导出按钮
                columns: [
                    [   
                        {checkbox: true},
                        {field: 'uid', title: __('Uid')},
                        {field: 'nickname', title: __('Nickname')},
						{field: 'sex', title: __('Sex'),operate: false},
                        {field: 'diamond', title: __('Diamond'),operate: false},
                        //{field: 'level', title: __('Level'),operate: false},
                        //{field: 'exp', title: __('Exp'),operate: false},
						{field: 'createTime', title: __('CreateTime'), formatter: Table.api.formatter.datetimes, operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"', style: 'min-width:90px;'},
                        //{field: 'device', title: __('Device'),operate: false},
                        //{field: 'agency', title: __('Agency'),operate: false},
                        //{field: 'ip', title:__('IP'),operate: false},
                        {field: 'loginnum', title:__('Loginnum'),operate: false},
                        {field: 'lastLoginTime', title: __('Lastlogintime'),formatter: Table.api.formatter.datetimes,operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"', style: 'min-width:90px;'},
						//{field: 'passwd', title: __('Passwd'),operate: false},
					]
                ],
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
			
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});